package com.tzz.utils;

import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.File;
import java.io.IOException;
import java.util.Map;

public class ModelDataUtil {
    final static String cla_path = new ModelDataUtil().getClass().getClassLoader().getResource("").getPath()+"/data_model/";

    /**
     * 根据名称读取请求体模板
     * */
    public static JSONObject getRequestDataModel(String fileName)  {
        String file_path = cla_path+fileName+".json";
        System.out.println("===========================================");
//        System.out.println(file_path);
        Map map = null;
        try {
            map = new ObjectMapper().readValue(new File(file_path), Map.class);
        } catch (IOException e) {
            e.printStackTrace();
        }
        JSONObject jsonObject = new JSONObject(map);
        return jsonObject;
    }
}
